/*
	名称：天空之城整形
	内容：更换脸型和眼睛颜色
*/

var status = -1;
var mFace = new Array(
					20000,20001,20002,20003,20004,20005,20006,20007,20008,20009,
					20010,20011,20012,20013,20014,20015,20016,20017,20018,20019,
					20020,20021,20022,20023,20024,20025,20026,20027,20028,20029,
					20030,20031,20032,20033,20035,20036,20037,20038,20040,20043,
					20044,20045,20046,20047,20048,20049,20050,20051,20052,20053,
					20054,20055,20056,20057,20058,20059,20060,20061,20062,20063,
					20064,20065,20066,20067,20068,20069,20070,20071,20072,20074,
					20075,20076,20077,20080,20081,20082,20083,20084,20085,20086,
					20087,20088,20089,20090,20093,20094,20095,20096,20097,20098,
					20099,23000,23001,23002,23003,23004,23005,23006,23008,23010,
					23013,23014,23016,23018,23020,23021,23023
					);
var fFace = new Array(
					21000,21001,21002,21003,21004,21005,21006,21007,21008,21009,
					21010,21011,21012,21013,21014,21015,21016,21017,21018,21019,
					21020,21021,21022,21023,21024,21025,21026,21027,21028,21029,
					21030,21031,21033,21034,21035,21036,21038,21041,21042,21043,
					21044,21045,21046,21047,21048,21049,21050,21052,21053,21054,
					21055,21056,21057,21058,21059,21060,21061,21062,21063,21064,
					21065,21066,21067,21069,21070,21071,21072,21073,21074,21075,
					21077,21078,21079,21080,21081,21082,21083,21084,21085,21086,
					21089,21090,21091,21092,21093,21094,21095,21096,21097,21098,
					21099,24001,24002,24003,24004,24007,24009,24010,24011,24012,
					24014,24016,24101,24102,24103,24104,24107,24109,24110,24111,
					24112,24114,24116
					);
var card = 5152057; // 万能高级整形卡
var showFace; // 需要显示的发型的数组

function start() {
	action(1, 0, 0);
}

function action (mode, type, selection) {
	if (mode == 0) {
		cm.dispose();
		return;
	} else {
		status++;
	}

	if (status == 0) {
		var text = "您好，我是全球极具权威的整容大师#p" + cm.getNpc() + "#，想变得更漂亮更帅气吗？来试试我的高科技吧！\r\n\r\n";
		text += "#b#L0# 改变脸型";
		cm.sendSimple(text);
	} else if (status == 1) {
		var text = "选择您满意的脸型吧，如果你有#b#t" + card + "##k的话，我可以帮你整出令人惊艳的脸型。";
		var Face = cm.getPlayer().getGender() == 0 ? mFace : fFace;
		var base = cm.getPlayer().getGender() == 0 ? 200 : 210;
		showFace = new Array();

		if (selection == 0) {
			var currFacecolor = Math.floor(cm.getPlayerStat("FACE")/100) % base;
			for (var i = 0; i < Face.length; i++) {
				showFace[i] = Face[i] + currFacecolor * 100;
			}
		}
		cm.sendStyle(text, showFace, card);
	} else if (status == 2) {
		if (cm.setAvatar(card, showFace[selection < 0 ? (selection += 256) : selection]) == 1) {
			cm.sendOk("矮油，看看看看，太漂亮了有木有？");
		} else {
			cm.sendOk("你没有#b#t" + card + "##k，可以先去商城购买。");
		}
		cm.dispose();
	}
}